package com.snowj.apaas.repository.auto;

import static com.snowj.apaas.repository.auto.TrademarkDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.snowj.apaas.domain.auto.Trademark;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface TrademarkMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.896099+08:00", comments="Source Table: trademark")
    BasicColumn[] selectList = BasicColumn.columnList(id, salesman, date, createdBy, createdDate, lastModifiedBy, lastModifiedDate, contractNumber, clientId, trademarkName, trademarkType, trademarkNumber, trademarkStarttime, trademarkEndtime, signMoney, contacts, contactNumber, contractAddress, remarks);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.893516+08:00", comments="Source Table: trademark")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.893616+08:00", comments="Source Table: trademark")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.893728+08:00", comments="Source Table: trademark")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    @Options(useGeneratedKeys=true,keyProperty="record.id")
    int insert(InsertStatementProvider<Trademark> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.893983+08:00", comments="Source Table: trademark")
    @Insert({
        "${insertStatement}"
    })
    @Options(useGeneratedKeys=true,keyProperty="records.id")
    int insertMultiple(@Param("insertStatement") String insertStatement, @Param("records") List<Trademark> records);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.89416+08:00", comments="Source Table: trademark")
    default int insertMultiple(MultiRowInsertStatementProvider<Trademark> multipleInsertStatement) {
        return insertMultiple(multipleInsertStatement.getInsertStatement(), multipleInsertStatement.getRecords());
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.894286+08:00", comments="Source Table: trademark")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("TrademarkResult")
    Optional<Trademark> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.894431+08:00", comments="Source Table: trademark")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TrademarkResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="salesman", property="salesman", jdbcType=JdbcType.VARCHAR),
        @Result(column="date", property="date", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="created_by", property="createdBy", jdbcType=JdbcType.VARCHAR),
        @Result(column="created_date", property="createdDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="last_modified_by", property="lastModifiedBy", jdbcType=JdbcType.VARCHAR),
        @Result(column="last_modified_date", property="lastModifiedDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="contract_number", property="contractNumber", jdbcType=JdbcType.VARCHAR),
        @Result(column="client_id", property="clientId", jdbcType=JdbcType.BIGINT),
        @Result(column="trademark_name", property="trademarkName", jdbcType=JdbcType.VARCHAR),
        @Result(column="trademark_type", property="trademarkType", jdbcType=JdbcType.VARCHAR),
        @Result(column="trademark_number", property="trademarkNumber", jdbcType=JdbcType.VARCHAR),
        @Result(column="trademark_starttime", property="trademarkStarttime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="trademark_endtime", property="trademarkEndtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="sign_money", property="signMoney", jdbcType=JdbcType.REAL),
        @Result(column="contacts", property="contacts", jdbcType=JdbcType.VARCHAR),
        @Result(column="contact_number", property="contactNumber", jdbcType=JdbcType.VARCHAR),
        @Result(column="contract_address", property="contractAddress", jdbcType=JdbcType.VARCHAR),
        @Result(column="remarks", property="remarks", jdbcType=JdbcType.VARCHAR)
    })
    List<Trademark> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.894751+08:00", comments="Source Table: trademark")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.89487+08:00", comments="Source Table: trademark")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, trademark, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.894983+08:00", comments="Source Table: trademark")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, trademark, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.89508+08:00", comments="Source Table: trademark")
    default int deleteByPrimaryKey(Long id_) {
        return delete(c -> 
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.895183+08:00", comments="Source Table: trademark")
    default int insert(Trademark record) {
        return MyBatis3Utils.insert(this::insert, record, trademark, c ->
            c.map(salesman).toProperty("salesman")
            .map(date).toProperty("date")
            .map(createdBy).toProperty("createdBy")
            .map(createdDate).toProperty("createdDate")
            .map(lastModifiedBy).toProperty("lastModifiedBy")
            .map(lastModifiedDate).toProperty("lastModifiedDate")
            .map(contractNumber).toProperty("contractNumber")
            .map(clientId).toProperty("clientId")
            .map(trademarkName).toProperty("trademarkName")
            .map(trademarkType).toProperty("trademarkType")
            .map(trademarkNumber).toProperty("trademarkNumber")
            .map(trademarkStarttime).toProperty("trademarkStarttime")
            .map(trademarkEndtime).toProperty("trademarkEndtime")
            .map(signMoney).toProperty("signMoney")
            .map(contacts).toProperty("contacts")
            .map(contactNumber).toProperty("contactNumber")
            .map(contractAddress).toProperty("contractAddress")
            .map(remarks).toProperty("remarks")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.895401+08:00", comments="Source Table: trademark")
    default int insertMultiple(Collection<Trademark> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, trademark, c ->
            c.map(salesman).toProperty("salesman")
            .map(date).toProperty("date")
            .map(createdBy).toProperty("createdBy")
            .map(createdDate).toProperty("createdDate")
            .map(lastModifiedBy).toProperty("lastModifiedBy")
            .map(lastModifiedDate).toProperty("lastModifiedDate")
            .map(contractNumber).toProperty("contractNumber")
            .map(clientId).toProperty("clientId")
            .map(trademarkName).toProperty("trademarkName")
            .map(trademarkType).toProperty("trademarkType")
            .map(trademarkNumber).toProperty("trademarkNumber")
            .map(trademarkStarttime).toProperty("trademarkStarttime")
            .map(trademarkEndtime).toProperty("trademarkEndtime")
            .map(signMoney).toProperty("signMoney")
            .map(contacts).toProperty("contacts")
            .map(contactNumber).toProperty("contactNumber")
            .map(contractAddress).toProperty("contractAddress")
            .map(remarks).toProperty("remarks")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.895624+08:00", comments="Source Table: trademark")
    default int insertSelective(Trademark record) {
        return MyBatis3Utils.insert(this::insert, record, trademark, c ->
            c.map(salesman).toPropertyWhenPresent("salesman", record::getSalesman)
            .map(date).toPropertyWhenPresent("date", record::getDate)
            .map(createdBy).toPropertyWhenPresent("createdBy", record::getCreatedBy)
            .map(createdDate).toPropertyWhenPresent("createdDate", record::getCreatedDate)
            .map(lastModifiedBy).toPropertyWhenPresent("lastModifiedBy", record::getLastModifiedBy)
            .map(lastModifiedDate).toPropertyWhenPresent("lastModifiedDate", record::getLastModifiedDate)
            .map(contractNumber).toPropertyWhenPresent("contractNumber", record::getContractNumber)
            .map(clientId).toPropertyWhenPresent("clientId", record::getClientId)
            .map(trademarkName).toPropertyWhenPresent("trademarkName", record::getTrademarkName)
            .map(trademarkType).toPropertyWhenPresent("trademarkType", record::getTrademarkType)
            .map(trademarkNumber).toPropertyWhenPresent("trademarkNumber", record::getTrademarkNumber)
            .map(trademarkStarttime).toPropertyWhenPresent("trademarkStarttime", record::getTrademarkStarttime)
            .map(trademarkEndtime).toPropertyWhenPresent("trademarkEndtime", record::getTrademarkEndtime)
            .map(signMoney).toPropertyWhenPresent("signMoney", record::getSignMoney)
            .map(contacts).toPropertyWhenPresent("contacts", record::getContacts)
            .map(contactNumber).toPropertyWhenPresent("contactNumber", record::getContactNumber)
            .map(contractAddress).toPropertyWhenPresent("contractAddress", record::getContractAddress)
            .map(remarks).toPropertyWhenPresent("remarks", record::getRemarks)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.896216+08:00", comments="Source Table: trademark")
    default Optional<Trademark> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, trademark, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.896336+08:00", comments="Source Table: trademark")
    default List<Trademark> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, trademark, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.896451+08:00", comments="Source Table: trademark")
    default List<Trademark> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, trademark, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.896554+08:00", comments="Source Table: trademark")
    default Optional<Trademark> selectByPrimaryKey(Long id_) {
        return selectOne(c ->
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.89666+08:00", comments="Source Table: trademark")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, trademark, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.896767+08:00", comments="Source Table: trademark")
    static UpdateDSL<UpdateModel> updateAllColumns(Trademark record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(salesman).equalTo(record::getSalesman)
                .set(date).equalTo(record::getDate)
                .set(createdBy).equalTo(record::getCreatedBy)
                .set(createdDate).equalTo(record::getCreatedDate)
                .set(lastModifiedBy).equalTo(record::getLastModifiedBy)
                .set(lastModifiedDate).equalTo(record::getLastModifiedDate)
                .set(contractNumber).equalTo(record::getContractNumber)
                .set(clientId).equalTo(record::getClientId)
                .set(trademarkName).equalTo(record::getTrademarkName)
                .set(trademarkType).equalTo(record::getTrademarkType)
                .set(trademarkNumber).equalTo(record::getTrademarkNumber)
                .set(trademarkStarttime).equalTo(record::getTrademarkStarttime)
                .set(trademarkEndtime).equalTo(record::getTrademarkEndtime)
                .set(signMoney).equalTo(record::getSignMoney)
                .set(contacts).equalTo(record::getContacts)
                .set(contactNumber).equalTo(record::getContactNumber)
                .set(contractAddress).equalTo(record::getContractAddress)
                .set(remarks).equalTo(record::getRemarks);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.897084+08:00", comments="Source Table: trademark")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(Trademark record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(salesman).equalToWhenPresent(record::getSalesman)
                .set(date).equalToWhenPresent(record::getDate)
                .set(createdBy).equalToWhenPresent(record::getCreatedBy)
                .set(createdDate).equalToWhenPresent(record::getCreatedDate)
                .set(lastModifiedBy).equalToWhenPresent(record::getLastModifiedBy)
                .set(lastModifiedDate).equalToWhenPresent(record::getLastModifiedDate)
                .set(contractNumber).equalToWhenPresent(record::getContractNumber)
                .set(clientId).equalToWhenPresent(record::getClientId)
                .set(trademarkName).equalToWhenPresent(record::getTrademarkName)
                .set(trademarkType).equalToWhenPresent(record::getTrademarkType)
                .set(trademarkNumber).equalToWhenPresent(record::getTrademarkNumber)
                .set(trademarkStarttime).equalToWhenPresent(record::getTrademarkStarttime)
                .set(trademarkEndtime).equalToWhenPresent(record::getTrademarkEndtime)
                .set(signMoney).equalToWhenPresent(record::getSignMoney)
                .set(contacts).equalToWhenPresent(record::getContacts)
                .set(contactNumber).equalToWhenPresent(record::getContactNumber)
                .set(contractAddress).equalToWhenPresent(record::getContractAddress)
                .set(remarks).equalToWhenPresent(record::getRemarks);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.897413+08:00", comments="Source Table: trademark")
    default int updateByPrimaryKey(Trademark record) {
        return update(c ->
            c.set(salesman).equalTo(record::getSalesman)
            .set(date).equalTo(record::getDate)
            .set(createdBy).equalTo(record::getCreatedBy)
            .set(createdDate).equalTo(record::getCreatedDate)
            .set(lastModifiedBy).equalTo(record::getLastModifiedBy)
            .set(lastModifiedDate).equalTo(record::getLastModifiedDate)
            .set(contractNumber).equalTo(record::getContractNumber)
            .set(clientId).equalTo(record::getClientId)
            .set(trademarkName).equalTo(record::getTrademarkName)
            .set(trademarkType).equalTo(record::getTrademarkType)
            .set(trademarkNumber).equalTo(record::getTrademarkNumber)
            .set(trademarkStarttime).equalTo(record::getTrademarkStarttime)
            .set(trademarkEndtime).equalTo(record::getTrademarkEndtime)
            .set(signMoney).equalTo(record::getSignMoney)
            .set(contacts).equalTo(record::getContacts)
            .set(contactNumber).equalTo(record::getContactNumber)
            .set(contractAddress).equalTo(record::getContractAddress)
            .set(remarks).equalTo(record::getRemarks)
            .where(id, isEqualTo(record::getId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.908391+08:00", comments="Source Table: trademark")
    default int updateByPrimaryKeySelective(Trademark record) {
        return update(c ->
            c.set(salesman).equalToWhenPresent(record::getSalesman)
            .set(date).equalToWhenPresent(record::getDate)
            .set(createdBy).equalToWhenPresent(record::getCreatedBy)
            .set(createdDate).equalToWhenPresent(record::getCreatedDate)
            .set(lastModifiedBy).equalToWhenPresent(record::getLastModifiedBy)
            .set(lastModifiedDate).equalToWhenPresent(record::getLastModifiedDate)
            .set(contractNumber).equalToWhenPresent(record::getContractNumber)
            .set(clientId).equalToWhenPresent(record::getClientId)
            .set(trademarkName).equalToWhenPresent(record::getTrademarkName)
            .set(trademarkType).equalToWhenPresent(record::getTrademarkType)
            .set(trademarkNumber).equalToWhenPresent(record::getTrademarkNumber)
            .set(trademarkStarttime).equalToWhenPresent(record::getTrademarkStarttime)
            .set(trademarkEndtime).equalToWhenPresent(record::getTrademarkEndtime)
            .set(signMoney).equalToWhenPresent(record::getSignMoney)
            .set(contacts).equalToWhenPresent(record::getContacts)
            .set(contactNumber).equalToWhenPresent(record::getContactNumber)
            .set(contractAddress).equalToWhenPresent(record::getContractAddress)
            .set(remarks).equalToWhenPresent(record::getRemarks)
            .where(id, isEqualTo(record::getId))
        );
    }
}